package com.whfc.ms.api.mach.service.impl;

import com.whfc.common.result.ListData;
import com.whfc.common.result.PageData;
import com.whfc.entity.dto.OssPathDTO;
import com.whfc.fuum.service.SysDeptService;
import com.whfc.mach.dto.obd.MaintainNumStatDTO;
import com.whfc.mach.dto.obd.MaintainRuleDTO;
import com.whfc.mach.dto.obd.ObdMaintainDTO;
import com.whfc.mach.param.MaintainHandleParam;
import com.whfc.mach.param.MaintainRuleSetParam;
import com.whfc.mach.service.ObdMaintainService;
import com.whfc.ms.api.mach.service.MsObdMaintainService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author sun_guodong
 * @description
 * @date 2021-03-05
 */
@Service
public class MsObdMaintainServiceImpl implements MsObdMaintainService {
    @DubboReference(interfaceClass = ObdMaintainService.class, version = "1.0.0")
    private ObdMaintainService obdMaintainService;

    @DubboReference(interfaceClass = SysDeptService.class, version = "1.0.0")
    private SysDeptService deptService;

    @Override
    public PageData<ObdMaintainDTO> list(Integer deptId, Integer pageNum, Integer pageSize, Integer state, Date startTime, Date endTime) {
        List<Integer> deptIds = deptService.getDescendantDeptIdList(deptId);
        return obdMaintainService.list(deptIds, pageNum, pageSize, state, startTime, endTime);
    }

    @Override
    public MaintainNumStatDTO numStat(Integer deptId) {
        List<Integer> deptIds = deptService.getDescendantDeptIdList(deptId);
        return obdMaintainService.numStat(deptIds);
    }

    @Override
    public ObdMaintainDTO detail(Integer maintainId) {
        return obdMaintainService.detail(maintainId);
    }

    @Override
    public void handle(MaintainHandleParam param) {
        obdMaintainService.handle(param);
    }

    @Override
    public void ruleSet(MaintainRuleSetParam param) {
        obdMaintainService.ruleSet(param);
    }

    @Override
    public ListData<MaintainRuleDTO> ruleDetail(Integer deptId) {
        return obdMaintainService.ruleDetail(deptId);
    }

    @Override
    public PageData<ObdMaintainDTO> getMaintainData(Integer machId, Integer pageNum, Integer pageSize) {
        return obdMaintainService.getMaintainData(machId, pageNum, pageSize);
    }

    @Override
    public OssPathDTO export(Integer machId) {
        String path = obdMaintainService.export(machId);
        return new OssPathDTO(path);
    }

    @Override
    public ObdMaintainDTO getNeedMaintainInfo(Integer machId) {
        return obdMaintainService.getNeedMaintainInfo(machId);
    }
}
